﻿<Common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="Antares.VIEWs.SnapView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Antares.VIEWs"
    xmlns:common="using:Antares.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Common="using:AntaresShell.Common"
    xmlns:viewmodel="using:Antares.VIEWMODELs" xmlns:Converters="using:Antares.Converters" mc:Ignorable="d"
    d:DesignWidth="320">
    
    <Page.DataContext>
        <viewmodel:SnapViewModel/>
    </Page.DataContext>
    
        <Page.Resources>
        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">My Application</x:String>
        <DataTemplate
                x:Key="DayItemTemplate">
            <local:DayItem/>
        </DataTemplate>
        <Converters:DateToShortStringConverter x:Key="DateToShortStringConverter"/>
        <Converters:WeatherTypeToPathConverter x:Key="WeatherTypeToPathConverter"/>
        <Converters:TemperatureToStringConverter x:Key="CelsiusToStringConverter"/>
        <Converters:IntToShortTimeConverter x:Key="IntToShortTimeConverter"/>
        <Converters:NullToVisibleConverter x:Key="NullToVisibleConverter"/>
        <Converters:OneThirdConverter x:Key="OneThirdConverter"/>

        <Style x:Key="dayGridStyle" TargetType="Grid">
            <Setter Property="Transitions">
                <Setter.Value>
                    <TransitionCollection>

                    </TransitionCollection>
                </Setter.Value>
            </Setter>
        </Style>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}"
          Width="320"
          Background="{StaticResource SnapBackground}">
        <Grid.RowDefinitions>
            <RowDefinition Height="115"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="80"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <TextBlock x:Name="pageTitle" Grid.Column="1" Text="Esec" Foreground="White" FontSize="60" Style="{StaticResource PageHeaderTextStyle}"/>
        </Grid>

        <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Left">
            <Button x:Name="HomeBtn"
                    Style="{StaticResource HomeAppBarButtonStyle2}"
                    Command="{Binding GoHomeCommand}"
                    Foreground="White"
					Margin="0,0,10,0" 
                    AutomationProperties.Name="{Binding Resource[Appbar_Home]}"/>
            <Button x:Name="ProjectBtn"
                    Style="{StaticResource WorldAppBarButtonStyle2}"
                    Command="{Binding ProjectCommand}"
                    Foreground="White"
					Margin="0,0,10,0" 
                    AutomationProperties.Name="{Binding Resource[Appbar_Project]}"/>
            <Button x:Name="BasicMonthBtn"
                    Style="{StaticResource CalendarAppBarButtonStyle2}"
                    Command="{Binding BasicMonthCommand}"
                    Foreground="White"
					Margin="0,0,10,0" 
                    AutomationProperties.Name="{Binding Resource[Appbar_BasicMonth]}"/>

        </StackPanel>

        <Grid Grid.Row="2"
                  Margin="30,0,30,30">
            <Grid x:Name="snapDayGrid" Style="{StaticResource dayGridStyle}" Background="#AF3C81BA"  >

                <Grid.RowDefinitions>
                    <RowDefinition Height="10"/>
                    <RowDefinition Height="24"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="20"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="10"/>
                    <ColumnDefinition Width="*" x:Name="Test"/>
                    <ColumnDefinition Width="10"/>
                </Grid.ColumnDefinitions>

                <TextBlock  Grid.Row="3" Grid.Column="1" Text="{Binding Day.Today, Converter={StaticResource DateToShortStringConverter}}" FontSize="42" HorizontalAlignment="Center" FontWeight="Light" VerticalAlignment="Bottom" Foreground="White"/>
                <Image Grid.Row="2" Grid.Column="1" Source="{Binding Day.WeatherModel.WeatherType, Converter={StaticResource WeatherTypeToPathConverter}}"/>

                <Image Grid.Row="2" Grid.Column="1" Source="../Assets/LinesTime_03.png" Width="{Binding ActualWidth, ElementName=Test}" Height="{Binding ActualWidth, ElementName=Test}" Opacity="0"/>

                <ProgressRing Visibility="{Binding Day.WeatherModel.WeatherType, Converter={StaticResource NullToVisibleConverter}}" Grid.Row="2" Grid.Column="1" Opacity=".2" Width="{Binding ActualWidth, ElementName=Test, Converter={StaticResource OneThirdConverter}}" Height="{Binding ActualWidth, ElementName=Test, Converter={StaticResource OneThirdConverter}}" IsActive="True"/>
                <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
                    <Image Source="../Assets/TempIcon.png" VerticalAlignment="Center"/>
                    <TextBlock  HorizontalAlignment="Left" TextWrapping="Wrap" Margin="5,0,5,0" Text="{Binding Day.WeatherModel, Converter={StaticResource CelsiusToStringConverter}}" VerticalAlignment="Center" FontSize="20" FontWeight="SemiLight" FontFamily="Segoe UI Light" Foreground="White"/>
                </StackPanel>
                <Grid Margin="0,10,0,0" Grid.Row="4" Grid.Column="1" VerticalAlignment="Bottom" >
                    <ListBox VerticalAlignment="Bottom" MaxHeight="210"  x:Name="TaskListInfo"  ItemsSource="{Binding Day.TaskList}" Background="{x:Null}" FontSize="20" BorderBrush="{x:Null}" FontWeight="SemiLight" FontFamily="Segoe UI Light" Style="{StaticResource ListBoxStyle1}" ItemContainerStyle="{StaticResource ListBoxItemStyle1}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                    <TextBlock Text="{Binding StartTime, Converter={StaticResource IntToShortTimeConverter}}" FontSize="20" FontWeight="SemiLight" Foreground="White"/>
                                    <TextBlock Text=":" Margin="0,0,2,0" Foreground="White" FontSize="20" FontWeight="SemiLight"/>
                                    <TextBlock Text="{Binding Name}" FontSize="20" Foreground="White" FontWeight="SemiLight"/>
                                </StackPanel>
                            </DataTemplate>

                        </ListBox.ItemTemplate>
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VirtualizingStackPanel>
                                    <VirtualizingStackPanel.ChildrenTransitions>
                                        <TransitionCollection>
                                            <EntranceThemeTransition />
                                        </TransitionCollection>
                                    </VirtualizingStackPanel.ChildrenTransitions>
                                </VirtualizingStackPanel>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                </Grid>
            </Grid>
        </Grid>
        
        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        
        <Grid.Transitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.Transitions>
    </Grid>
</Common:LayoutAwarePage>
